package com.oyb.servlet;

import com.oyb.entity.Classes;
import com.oyb.service.ClassServies;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/subupdateclass")
public class ClassesupdateServlet extends HttpServlet {
    private ClassServies classServies = new ClassServies();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String id = req.getParameter("id");
        String class_name = req.getParameter("class_name");
        Classes classes = new Classes();
        classes.setId(Integer.parseInt(id));
        classes.setClass_name(class_name);
        int result = classServies.updateclass(classes);
        if(result>0){
            resp.sendRedirect("classesquerypage");
        }

    }
}
